<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" session="true"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%!
	String campo1;
	String campo2;
	String campo3;
	String inputType;
	String submitValue;
	String formAction;
	%>
	<%
	session.setMaxInactiveInterval(10);
	campo1 = (String) session.getAttribute("campo1");
	campo2 = (String) session.getAttribute("campo2");
	campo3 = (String) session.getAttribute("campo3");
	if(campo1 != null && campo2 != null && campo3 != null){
		inputType = "hidden";
		submitValue = "confirmar valores";
		formAction = "";
	} else{
		inputType = "text";
		submitValue = "Enviar";
		formAction = "ex04.jsp";
		campo1 = request.getParameter("campo1");
		campo2 = request.getParameter("campo2");
		campo3 = request.getParameter("campo3");
		if(campo1 != null && campo2 != null && campo3 != null){
			session.setAttribute("campo1", campo1);
			session.setAttribute("campo2", campo2);
			session.setAttribute("campo3", campo3);
			inputType = "hidden";
			submitValue = "confirmar valores";
			formAction = "";
		}
	}
	%>
	<%= (inputType == "hidden")?"<p>Sess&atilde;o encerrar&aacute; ap&oacute;s"+
						"10 segundos de inatividade.</p>":"" %>	
		<form action="<%= formAction%>" method="POST">
			<label for="campo1">campo1: </label>
			<%= (inputType == "hidden")?campo1:"" %>
			<input type="<%= inputType %>" name="campo1" id="campo1" <%= (inputType == "hidden")?"value='"+campo1+"'":""%>>
			<label for="campo2">campo2: </label>
			<%= (inputType == "hidden")?campo2:"" %>
			<input type="<%= inputType %>" name="campo2" id="campo2" <%= (inputType == "hidden")?"value='"+campo2+"'":""%>>
			<label for="campo3">campo3: </label>
			<%= (inputType == "hidden")?campo3:"" %>
			<input type="<%= inputType %>" name="campo3" id="campo3" <%= (inputType == "hidden")?"value='"+campo3+"'":""%>>
			<input type="submit" value="<%= submitValue %>">
		</form>
</body>
</html>